import pymysql
from pyecharts.charts import Bar
from  pyecharts import options
db=pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='458092',
    database='crawlerdemo',
    charset='utf8',
)

cursor=db.cursor()
sql="select min(job_sal),job_place from job group by job_place order by min(job_sal) limit 5"
sal=[]
city=[]
try:
    cursor.execute(sql)
    res=cursor.fetchall()
    for i in res:
        sal.append(i[0])
        city.append(i[1])
except:
    print("查询出问题了")
bar=Bar()
bar.add_xaxis(city)
bar.add_yaxis("月薪水/元",sal)
bar.set_global_opts(title_opts=options.TitleOpts(title="五个城市的最低工资",subtitle="单位/元"))
bar.render("barlowest.html")

cursor.close()
db.close()